#ifndef CHANNELLIST_H
#define CHANNELLIST_H

#include <QObject>
#include <QList>
#include <QFutureWatcher>
#include <QDateTime>

class Channel;

class ChannelList : public QObject
{
    Q_OBJECT
    
public:
    ChannelList(QObject* parent = 0);
    ~ChannelList();
    
public:
    int count() const;
    Channel* at(int index) const;
    
private:
    void updateThreadFunc(bool force);
    bool updateChannels();

public slots:
    void update(bool force = false);
    void cancel();

signals:
    void updated(bool success);
    void progressInfo(const QString& channelName, int channel, int numChannels);

private:
    QList<Channel*> channels;
    QFutureWatcher<void> watcher;
    QDateTime lastUpdate;
    bool canceled;
};

#endif // CHANNELLIST_H
